/*
*
* ModeSelector
*
* This class controls the pull down selector used to select the drawing mode
*
*/
class ModeSelectorUI {
  
  // ---------------------------------
  // attributes
  // ---------------------------------
  ControlP5 controlp5;
  PApplet parent;
  ListBox modeSelector;
  String[] modeNames;
  int origX, origY, wid, hei;
  
  // ----------------------------------
  // constructor
  // ----------------------------------
  ModeSelectorUI(ControlP5 cp5, PApplet p55, String[] mn, int x, int y, int w, int h) {
    
    // assign attributes
    controlp5 = cp5;
    parent = p55;
    modeNames = mn;
    origX = x;
    origY = y;
    wid = w;
    hei = h;
    
    // create mode selection list box using ControlP5 ListBox class
    // NOTE: SCROLL BAR NOT CURRENTLY IMPLEMENTED -- SEE ISSUES ON GOOGLE CODE PAGE
    modeSelector = controlp5.addListBox("modeSelector", origX, origY, wid, hei);    // create ListBox
    modeSelector.setItemHeight(15);                                                  // set height for ListBox items
    modeSelector.setBarHeight(15);                                                  // set height of caption box
    modeSelector.captionLabel().toUpperCase(true);                                  // display ListBox caption in uppercase
    modeSelector.captionLabel().set("Drawing Mode");                                // set value for ListBox caption
    modeSelector.captionLabel().style().marginTop = 3;                              // set padding between Label and its borders
    modeSelector.captionLabel().style().marginLeft = 2;
    modeSelector.valueLabel().style().marginTop = 3;                                // padding for the +/- sign
    modeSelector.setColorLabel(0);                                                  // set label colour
    modeSelector.setColorValue(0);                                                  // set values colour
    for(int i = 0; i < modeNames.length; i++) {
      modeSelector.addItem(modeNames[i], i);                                        // create ListBox items
    } // for loop
    modeSelector.setColorBackground(color(50, 50));                                 // set background colour (everything except label box and scroll button)
    modeSelector.setColorForeground(color(50, 50));                                 // set foreground colour (label box and scroll button)
    modeSelector.setColorActive(color(0, 200, 200, 30));                            // list items are highlighted in this colour when the mouse is above them
    modeSelector.setId(1);                                                          // set ID of ListBox control group for event listening
    modeSelector.hide(); // hide ListBox so it isn't drawn twice; show() called during draw loop
  
  } // constructor method


  // ------------------------------------
  // draw
  // called during the sketch's draw loop
  // ------------------------------------
  void draw() {
  
    // draw list box
    modeSelector.show();
    
  } // draw method  
  
} // ModeSelector class
